home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / macros / plain / contrib / reference.tex < prev    next >
Encoding:
Text File  |  1992-08-26  |  7.2 KB  |  167 lines

  1. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  2. %                       Version 2.1
  3. %                         6/27/86
  4. % Written by: B.A. Leland (XHEMIA:BAL)
  5. %             Calif Inst of Technology
  6. % Recognizes only ascending sequential footnote numbers, prints
  7. %           everything else as read in the list
  8. % Required defs:
  9. % dash : defined as $^{-}$
  10. % checkref#1 : to determine if the reference has yet been
  11. %                    cited --- calls quickcnt
  12. % note#1 : initializes flags, counters, calls refext
  13. % refext#1 : does all the work, calls checkref, then prints
  14. %                  the footnote numbers.  If newref=true write the
  15. %                  reference to the output file with its footnote
  16. %                  number, and redefine the def of the reference to
  17. %                  equal the current footnote number.  If the
  18. %                  references are anything but ascending sequential
  19. %                  numbers, print the numbers separated by commas.
  20. %       quickcnt#1 : based on Knuth's length macro (TeXbook, p.219)
  21. %                    counts the no. of non-blank characters in the
  22. %                    reference.  If > or = 4, set the newref flag to
  23. %                    true.
  24. % Required misc:
  25. %       counters
  26. %               ftnum: previous footnote number of a newly cited ref
  27. %               prev: previous PRINTED footnote number
  28. %       flags
  29. %               dsh : true = enable dash printing for no. ranges
  30. %               newref : true = a reference that has not been cited
  31. %
  32. %\immediate\openout1=reflist % open the ouput file 'reflist.tex'
  33. %\newcount\ftnum   % footnote number counter
  34. %\newcount\prev    % previous footnote number
  35. %\newif\ifdsh      % dsh=true: enable "dash" printing for ranges of #s
  36. %\def\dash{$^{-}$} % a dash for ranges of numbers
  37. %---------------------------------------------------------------------
  38. %\def\note#1{{
  39. %\dshtrue  % toggle dsh flag to enable range printing
  40. %\prev=0   % initialize prev counter
  41. %\count0=0 % initialize cycle counter
  42. %\refext#1\end}}  % call refext with list of references as argument
  43. %---------------------------------------------------------------------
  44. %\def\refext#1{
  45. %\ifx#1\end   % \end is appended at end of reference list
  46. %    \ifdsh   % dsh=true do nothing
  47. %    \else $^{\number\prev}$\fi\let\next=\relax  % finish the range, quit
  48. %\else\checkref#1      % see if the reference has been cited previously
  49. %    \ifnewref\global\advance\ftnum by1 % new reference,
  50. %                                       % inc ftnum counter
  51. %        \immediate\write1{\noexpand\item{$^{\the\ftnum}$}#1}
  52. %        \xdef#1{\the\ftnum} % write the reference to the output file,
  53. %                            % and redefine the reference to be
  54. %                            % the current footnote number
  55. %    \fi
  56. %    \ifnum\count0=0 $^{#1}$ % first cycle, print the first no.
  57. %    \else \ifnum\prev=#1    % duplicate reference, ignore
  58. %          \else\advance\prev by1 % increment the prev counter
  59. %               \ifnum\prev=#1  % if true, sequence is sequential
  60. %                  \ifdsh          % if dsh enabled,
  61. %                      \dash       % print a dash for the range
  62. %                      \dshfalse   % and disable the dsh flag
  63. %                  \fi
  64. %               \else\ifdsh $^{,\,#1}$  % if dsh enabled, print ", #"
  65. %                    \else  % a dash was printed previously
  66. %                        \advance\prev by-1 % restore prev counter
  67. %                        $^{\number\prev ,\,#1}$ % finish the range, and
  68. %                                    % print the new (non-sequential) no.
  69. %                        \dshtrue  % toggle the dsh flag
  70. %                    \fi
  71. %               \fi
  72. %          \fi
  73. %    \fi
  74. %    \prev=#1 % save current footnote number in prev counter
  75. %    \advance\count0 by1  % increment cycle counter
  76. %    \let\next=\refext    % recursive call
  77. %\fi
  78. %\next}
  79. %+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  80. %\newcount\qckcntr
  81. %\newif\ifnewref   % newref=true: 1st occurance of a given reference
  82. %---------------------------------------------------------------------
  83. %\def\checkref#1{{
  84. %\global\newreffalse % toggle the newref flag
  85. %\qckcntr=0          % initialize cycle "register"
  86. %\expandafter\quickcnt#1\end % expand the passed reference appending \end
  87. %\relax}}
  88. %---------------------------------------------------------------------
  89. %\def\quickcnt#1{
  90. %\ifx#1\end \let\next=\relax % relax and quit
  91. %\else\advance\qckcntr by1   % increment cycle register
  92. %     \ifnum\qckcntr<4       % <4 cycles means nothing, so do nothing
  93. %     \else\global\newreftrue % >= 4 means the reference has not been
  94. %                             % previously cited, toggle the newref flag
  95. %     \fi
  96. %     \let\next=\quickcnt % recursive call
  97. %\fi
  98. %\next}
  99. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  100. %________________________BEGIN__DEFS__________________________________
  101. %
  102. \immediate\openout1=reflist % open the ouput file 'reflist.tex'
  103. \newcount\ftnum   % footnote number counter
  104. \newcount\prev    % previous footnote number
  105. \newif\ifdsh      % dsh=true: enable dash printing
  106. \def\dash{$^{-}$}
  107. \def\note#1{{\dshtrue \prev=0 \count0=0 \refext#1\end}}
  108. \def\refext#1{\ifx#1\end
  109. \ifdsh\else $^{\number\prev}$\fi\let\next=\relax
  110. \else\checkref#1\ifnewref\global\advance\ftnum by1 \immediate
  111. \write1{\noexpand\item{$^{\the\ftnum}$}#1}\xdef#1{\the\ftnum}\fi
  112. \ifnum\count0=0 $^{#1}$\else \ifnum\prev=#1 \else
  113. \advance\prev by1 \ifnum\prev=#1 \ifdsh \dash\dshfalse\fi\else
  114. \ifdsh $^{,\,#1}$\else
  115. \advance\prev by-1 $^{\number\prev ,\,#1}$\dshtrue \fi\fi\fi\fi
  116. \prev=#1 \advance\count0 by1 \let\next=\refext\fi \next}
  117. %
  118. \newcount\qckcntr
  119. \newif\ifnewref   % newref=true: 1st occurance of a given reference
  120. \def\checkref#1{{\global\newreffalse\qckcntr=0
  121. \expandafter\quickcnt#1\end \relax}}
  122. \def\quickcnt#1{\ifx#1\end \let\next=\relax
  123. \else\advance\qckcntr by1 \ifnum\qckcntr<4 \else\global\newreftrue\fi
  124. \let\next=\quickcnt\fi \next}
  125. %
  126. %__________________________END__DEFS__________________________________
  127. %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  128. %
  129. %           S   A   M   P   L   E        U   S   A   G   E
  130. %
  131. % \def\a{this is reference a}
  132. % \def\aaa{aaaaa}
  133. % \def\b{this is reference b which has \reff }
  134. % \def\c{this is reference c which has \reff }
  135. % \def\d{this is reference d which has \reff }
  136. % \def\e{this is reference e which has \reff }
  137. % \def\g{this is reference e which has \reff }
  138. % \def\reff{reference f}
  139. %
  140. % {\rm
  141. % \ftnum=9
  142. % This is the example\note{\a} of
  143. % a\note{\b} paragraph
  144. % which contains footnotes that will ultimately end up on
  145. % a reference page.
  146. % This is the
  147. % second\note{\a} which
  148. % is supposed to be the same as the first reference.
  149. % If we continue, we\note{\c\b} should get another
  150. % one\note{\d} and\note{\a} so\note{\e} on.
  151. % If one needs to recall a couple of references\note{\aaa} one
  152. % uses a the same macro\note{\a\b\c\d\e} as before.
  153. % It is supposed to handle\note{\a\b\d\e} most any situation
  154. % up to and almost including\note{\e\d\c\b\a} except
  155. % this\note{\b\a\d\e} or this.\note{\a\b\c\d\d}  One
  156. % must be cautioned that this has not been fully tested as yet..........
  157. % \vskip0.5truein
  158. % \immediate\closeout1
  159. % \vfill\eject
  160. % \baselineskip=14pt
  161. % \parindent=0pt
  162. % \parskip=0.1truein
  163. % \input reflist.tex
  164. % }
  165. % \vfill\end
  166. %
  167.